<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center schedulePage_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub schedulePage_fd0_0'>
          <view class='flex flex-wrap align-center schedulePage_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  schedulePage_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='schedulePage_fd0_0_c1_c0' v-if=" state=='1'">{{$t('添加日程')}}</text><text
              class='schedulePage_fd0_0_c1_c0' v-if=" state=='2'">{{$t('编辑日程')}}</text>
          </view>
          <view class='flex flex-wrap align-center justify-end schedulePage_fd0_0_c0' @click.stop="delRiqi">
            <text class='schedulePage_fd0_0_c2_c0' v-if=" richengneirong">{{$t('删除')}}</text>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout schedulePage_flex_1">
        <view class='flex flex-wrap align-center schedulePage_fd1_0'>
          <input type="text" :placeholder="$t('填写日程')" confirm-type="done" :maxlength="24"
            placeholder-style="color:rgba(51, 51, 51, 1);font-size:28rpx" v-model="richengneirong" />
        </view>
        <view class='flex flex-wrap align-center schedulePage_fd1_1'>
          <text class='schedulePage_fd1_1_c0'>{{$t('请设置2-24个字符，不包含@《/等无效字符哦')}}</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center schedulePage_flex_2">
        <button class='schedulePage_fd2_0' @tap.stop="submit('1')" data-type="back" data-url="1"
          v-if=" state=='1'">{{$t('添加')}}</button>
        <button class='schedulePage_fd2_0' @tap.stop="submit('2')" data-type="back" data-url="1"
          v-if=" state=='2'">{{$t('保存')}}</button>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "name": "",
        "state": "1",
        richengneirong: '',
        aid: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        name,
        state
      } = options
      if (name !== undefined) this.name = name
      if (state !== undefined) this.state = state
      this.getDetail()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      delRiqi() {
        this.$api.post(global.apiUrls.post65966d2c3eecc, {
          aid: this.aid
        }).then(res => {
          if (res.data.code == 1) {
            uni.navigateBack()
          }
        })
      },
      getDetail() {
        this.$api.dbPost(global.apiUrls.post65966d0f2cf06, {
          shijian: this.name
        }).then(res => {
          if (res.data.code == 1) {
            this.richengneirong = res.data.data.richengneirong
            this.aid = res.data.data.aid
          }
        })
      },
      submit(type) {
        let urls = ''
        if (type == 1) {
          urls = global.apiUrls.post659667dabbb23
        } else {
          urls = global.apiUrls.post65966d8312a96
        }
        if (!this.richengneirong) {
          this.$message.info(this.$t('请设置2-24个字符，不包含@《/等无效字符哦'))
          return
        }
        if (this.richengneirong.length < 2) {
          this.$message.info(this.$t('请设置2-24个字符，不包含@《/等无效字符哦'))
          return
        }
        this.$api.post(urls, {
          shijian: this.name,
          richengneirong: this.richengneirong
        }).then(res => {
          if (res.data.code == 1) {
            uni.navigateBack()
          }
        })
      },
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(247, 243, 237, 1);
    background-size: 100% auto;
  }

  .schedulePage_flex_0 {
    background: rgba(247, 243, 237, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .schedulePage_fd0_0_c2_c0 {
    color: #333333;
    font-size: 32rpx;
    font-weight: 500;
    line-height: 42rpx;
  }

  .schedulePage_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .schedulePage_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .schedulePage_fd0_0_c0 {
    width: 120rpx;
  }

  .schedulePage_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .schedulePage_flex_1 {
    padding: 32rpx 32rpx 0rpx 32rpx;
  }

  .schedulePage_fd1_1_c0 {
    color: #FD9A39;
    font-size: 26rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .schedulePage_fd1_1 {
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .schedulePage_fd1_0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 16rpx;
    background-size: 100% auto;
    padding: 16rpx 0rpx 16rpx 24rpx;
  }

  .schedulePage_flex_2 {
    position: fixed;
    bottom: calc(60rpx + var(--window-bottom));
    left: 32rpx;
  }

  .schedulePage_fd2_0 {
    background: rgba(145, 47, 34, 1);
    border-radius: 44rpx;
    width: 686rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }
</style>